<template>
  <div class="videoPictureList h100" v-loading="loading">
    <div class="pageContent">
      <el-row :gutter="11" class="fileSearch">
        <el-form
          :model="ruleForm"
          :inline="true"
          ref="ruleForm"
          label-width="80px"
        >
          <el-form-item label="用户名:" prop="name">
            <el-input v-model="ruleForm.name" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              icon="el-icon-search"
              type="primary"
              @click="onSubmit(1)"
            >
              查询
            </el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
      </el-row>
      <el-table
        :data="tableData"
        border
        :header-cell-style="{
          background: 'rgb(246,247,251)',
          color: '#606266'
        }"
        stripe
        class="defaultTableHeight"
      >
        <el-table-column type="index" label="编号" width="50">
        </el-table-column>
        <el-table-column prop="name" align="center" label="用户名">
        </el-table-column>
        <el-table-column prop="phone" align="center" label="手机号">
        </el-table-column>
        <el-table-column prop="date" align="center" label="时间">
        </el-table-column>
        <el-table-column label="上传的图片" align="center" width="300px">
          <template slot-scope="scope">
            <el-image
              style="width:100px;height:60px"
              :src="scope.row.imgs[0].url"
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="300px">
          <template slot-scope="scope">
            <el-button type="primary" size="mini">查看</el-button>
            <el-button type="danger" size="mini">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <p style="text-align: right; ">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pager.currentPage"
          :page-size="pager.pageSize"
          :page-sizes="[10, 20, 30, 50]"
          background
          layout="total,sizes,prev, pager, next, jumper"
          :total="pager.total"
        >
        </el-pagination>
      </p>
    </div>
  </div>
</template>

<script>
import { getVideoPictureList } from "@/api/appUser/videoPicture";
export default {
  name: "videoPictureList",
  data() {
    return {
      loading: false,
      ruleForm: {
        name: ""
      },
      pager: {
        pageSize: 20,
        total: 1,
        currentPage: 1
      },
      tableData: []
    };
  },
  mounted() {
    // this.onSubmit();
  },
  //注销window.onresize事件
  destroyed() {},
  methods: {
    async onSubmit(val) {
      if (val) {
        this.pager.currentPage = 1;
      }
      this.loading = true;
      var postData = {
        name: this.ruleForm.name,
        pageSize: this.pager.pageSize,
        currentPage: this.pager.currentPage
      };
      //查询接口
      let res = await getVideoPictureList(postData);
      console.log(res);
      this.loading = false;
      if (res.code !== "2000") {
        this.$message.error("数据读取失败");
        return;
      }
      this.tableData = res.data.list;
      this.pager = res.data.pager;
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.$refs["ruleForm"].resetFields();
      this.onSubmit();
    },
    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function(size) {
      this.pager.pageSize = size;
      this.onSubmit();
    },
    handleCurrentChange: function(currentPage) {
      this.pager.currentPage = currentPage;
      this.onSubmit(); //点击第几页
    }
  }
};
</script>

<style lang="scss" scoped></style>
